<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="编号"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="输入框名称"%>
<%@ attribute name="value" type="java.lang.String" required="true" description="输入框值"%>
<i id="${id}Icon" class="${not empty value?value:'hide'}"></i>&nbsp;
<label id="${id}IconLabel">${not empty value?value:'无'}</label>&nbsp;
<input id="${id}" name="${name}" type="hidden" value="${value}"/>
<a id="${id}Button" href="javascript:" class="btn btn-primary btn-white">选择</a>&nbsp;&nbsp;
<script type="text/javascript">
	$("#${id}Button").click(function(){
		var id=$("#${id}").val();
		var height=$(top.document).height()-180;
		var pWidth=$(top.document).width();
		var width=pWidth-(pWidth>1024?500:100);
		top.layer.open({
			id:id,
			title:'选择图标',
			type:2,
			shade:0.2,
			content:'${ctx}/tag/iconselect?value=${id}&frame=<%=request.getAttribute("frame")%>',
			area: [width+'px', height+'px'],
			btn:['确定','清除','关闭'],
			yes: function(index, layero){
			    var icon = layero.find('iframe')[0].contentWindow.$("#icon").val();//h.find("iframe").contents();
			    if(icon==""){
			    	top.layer.alert('请选择图标！',{title:'提示'});
					return false;
			    }
			    var subr=6;
			    if(icon.indexOf('glyphicon')==0){
			    	subr=20;
			    }
            	$("#${id}Icon").attr("class", icon);
                $("#${id}IconLabel").text(icon.substring(subr));
                $("#${id}").val(icon);
				top.layer.close(index);
		  	},btn2: function(index, layero){
		  		$("#${id}Icon").removeAttr("class");
                $("#${id}IconLabel").text("无");
                $("#${id}").val("");
				top.layer.close(index);
		  	},btn3: function(index, layero){
		  		top.layer.close(index);
		  	},success:function(layero,index){
		  		$(".jbox-content", top.document).css("overflow-y","hidden");
		  	}
		});
		/* top.$.jBox.open("iframe:${ctx}/tag/iconselect?value="+$("#${id}").val(), "选择图标", 700, $(top.document).height()-180, {
            buttons:{"确定":"ok", "清除":"clear", "关闭":true}, submit:function(v, h, f){
                if (v=="ok"){
                	var icon = h.find("iframe")[0].contentWindow.$("#icon").val();
                	icon=$.trim(icon).substr(5);
                	$("#${id}Icon").attr("class", "icon-"+icon);
	                $("#${id}IconLabel").text("icon-"+icon);
	                $("#${id}").val(icon);
                }else if (v=="clear"){
	                $("#${id}Icon").attr("class", "icon-hide");
	                $("#${id}IconLabel").text("无");
	                $("#${id}").val("");
                }
            }, loaded:function(h){
                $(".jbox-content", top.document).css("overflow-y","hidden");
            }
        }); */
	});
</script>